/**
 * @description: uuid
 * @param template uuid模板 默认
 * @return string
 */
const generateUUID = (template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx") => {
    // Helper function to generate a random hex digit
    const randomHexDigit = (c) => {
        const r = crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c === "x" ? 0 : 4));
        return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
    };
    // Generate UUID based on template
    return template.replace(/[xy]/g, randomHexDigit);
};

export { generateUUID };
